<template>
  <view class='custom-info'>
	  <!-- 公共组件-每个页面必须引入 -->
	  <public-module></public-module>
    <view class="info-top">
      <view class="top-white">
        <view class="my-image">
          <u--image :showLoading="true" :src="supplierData.storeLogo" shape='circle' width="119rpx" height="119rpx"
            @click="click"></u--image>
        </view>
        <view class="custom-name">
          <view class="name">姓名：<text>{{supplierData.contactPerson}}</text></view>
          <view class="time">加入时间：<text>{{supplierData.createdAt}}</text></view>
        </view>
      </view>
    </view>
    <view class="info-middle">
      <view class="row u-flex bgrow" @tap.stop='notes'>
        <view class="nominal">
          设置备注
        </view>
        <view class="input">
          <u-icon slot="right" name="arrow-right" :customStyle="{marginLeft: '90%'}"></u-icon>
        </view>
      </view>
      <view class="row u-flex bgrow">
        <view class="nominal">
          置顶
        </view>
        <view class="input switch">
          <switch :checked="isTop" @change="isDefaultChange" />
        </view>
      </view>
    </view>

    <view class="info-list">
      <view class="info-list-name">
        <text>销售订单</text>
      </view>
      <view v-if='supplierData.order.length>0'>
        <view class="info-clone" v-for="(item,index) in supplierData.order" :key="index">
          <view class="list-top">
            <text class="top-left">{{item.categoryName}}/{{item.brandName}}/{{item.goodsSn}}</text>
            <text class="top-right">{{item.createdAt}}</text>
          </view>
          <view class="list-bottom">
            <text class="bottom-left">
              采购数量：<text>{{item.goodsNum}}</text>吨
            </text>
            <text class="bottom-right">分成<text>{{item.firstCommission}}</text>元</text>
          </view>
        </view>
      </view>

      <view class="scroll-zero" v-else>
        <text>--暂无订单--</text>
      </view>


    </view>
  </view>
</template>

<script>
  import {
    supplierDetail,
    editFans
  } from '@/config/api2.js'
  export default {
    data() {
      return {
        supplierData: {},
		isTop: 0,
		supplierId:''
      }
    },
    onLoad(e) {
	  this.supplierId = e.supplierId
    },
	
	onShow(){
	   this.getSupplierDetail()
	},
	
    methods: {
      getSupplierDetail() {
        supplierDetail({supplierId:this.supplierId}).then(res => {
          this.supplierData = res
           this.isTop = res.isTop==1 ? true : false
        })
      },

      isDefaultChange(e) {
        this.isTop = e.detail.value ? 1 : 0
        editFans({
         isTop: e.detail.value ? 1 : 0,
         userId: this.supplierData.userId,
         fansId:this.supplierData.fansId
        }).then(res => {

        })
      },
      notes() {
        uni.navigateTo({
          url: 'notes?userId=' + this.supplierData.userId
        })
      }
    }
  }
</script>

<style lang="scss">
  @import '@/style/wmj.scss';
.bgrow.row{
	  background: rgba(243,243,243,1);
	  border-radius: 18rpx;
  }
  .row {
    width: 690rpx;
    height: 79rpx;
    padding: 0 10rpx 0 30rpx;
    margin-bottom: 20rpx;
    background: #F3F3F3;
    border-radius: 18rpx;

    .nominal {
      width: 30%;
      height: 100upx;
      font-size: 26upx;
      line-height: 100upx;
      align-items: center;
    }

    .input {
      width: 100%;
      padding: 20upx 0;
      align-items: center;
      font-size: 30upx;
      text-align: right;

      &.switch {
        justify-content: flex-end;
      }

      .textarea {
        margin: 20upx 0;
        min-height: 120upx;
      }
    }

  }
</style>